﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace DataLayer.Model.Objects
{
    [DataContract]
    public class WorkProcess 
    {
        [DataMember]
        public List<Macro> Macroses;

        [DataMember]
        public bool Cyclic;
        [DataMember]
        public string Name;

        public WorkProcess()
        {
            Cyclic = false;
        }

        public void AddMacro(Macro pMacro)
        {
            if (Macroses == null)
                Macroses = new List<Macro>();
            Macroses.Add(pMacro);
        }
        public void SetRepeat(bool? pCyclic)
        {
            if (pCyclic == false || pCyclic == null)
                Cyclic = false;
            else
                Cyclic = true;
        }
        
        public void DoWork()
        {
            while (true)
            {
                foreach (var macros in Macroses)
                    macros.DoWork();
                if (!Cyclic)
                    break;
            }  
        }
    }
}
